#include <iostream>
#include <vector>

using namespace std;

static vector<uint64_t> prime_factorization(uint64_t n) {
    vector<uint64_t> factors;
    for (int i = 2; i * i <= n; ++i) {
        if (n % i == 0)
            factors.push_back(i);
        while (n % i == 0)
            n /= i;
    }
    if (n > 1)
        factors.push_back(n);
    return factors;
}

int main() {
    constexpr uint64_t limit = 1'000'000;
    vector<uint64_t> phi {0};
    for (auto i = 2; i <= limit; ++i) {
        vector<uint64_t> factors = prime_factorization(i);
        uint64_t num = i;
        for (auto p : factors)
            num = num / p * (p - 1);
        phi.push_back(num + phi.back());
    }
    cout << phi.back() << endl;
}
